<extend name="Index:base" />
<block name="title"><title>管理员</title></block>
<block name="style">
 <style>
.main,.panel-default>.panel-heading{
background:none;
}

body{
background:none;
}
.panel.panel-default,.panel .panel-body,.panel .panel-heading,.table-bordered {
	border:none;
}
.table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
	border:none;		
	padding:15px;	
	line-height:8px;
	height: 8px;
	border-top: 1px solid #d4d4d4;
	border-bottom: 1px solid #d4d4d4;
}
.name strong{
color:#000000;
font-size:15px;
font-weight:600;
}
.name {
	color:#20a8d8;
	font-size:12px;
}
.smallfont {
	color:#9c9c9c;
	font-size:12px;
}

.align-center{
	text-align:center; 
}
.title2{
text-align:center;
}
.table-bordered > tbody > tr .wd{
	text-align:left;	
}

.col-xs-2,.col-xs-4{
padding-right:0;
margin:10px 0;
}
 </style>
</block>
	<!-- start: Header -->
<block name="body">

			<!-- end: Main Menu -->
						
		<!-- start: Content -->
		<div class="main ">
		
			<div class="row">
				<div class="col-lg-12">
					<h3 class="page-header"><i class="fa fa-life-bouy"></i>管理员</h3>
				</div>
			</div>

			<div class="row">		
				<div class="col-lg-12">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h2><span class="break"></span><strong>管理员</strong></h2>&nbsp;&nbsp;&nbsp;
							<if condition="$level eq '2'">
							<a class="btn btn-success" role="button" data-toggle="modal" href="#again" id="add_right">添加管理员</i></a>
							</if>
														
						</div>&nbsp;&nbsp;&nbsp;
						<ol class="breadcrumb" style="height:55px;background-color: #ffffff;">							
							<li><i class="fa fa-warning"></i><a href="#">操作提示：</a></li><br/>	
							<li><font style="font-size:8px;color:#888;">通过会员管理，你可以进行查看、编辑会员资料等操作
							你可以根据条件搜索会员，然后选择相应的操作！</font></li>							
						</ol>
						<div class="panel-body">
							<table class="table table-striped table-bordered bootstrap-datatable datatable">
							  <thead>
								  <tr>
									  <th>ID</th>
                                      <th>管理员账号</th>
									  <th class="title2">创建时间</th>
									  <th class="title2">上次登录时间</th>
									  <th class="title2">上次登录IP</th>
									  <th class="title2">管理组</th>
									  <th class="title2">状态</th>
									  <th class="title2">操作</th>
								  </tr>
							  </thead>   
							  <tbody id="state">
								<volist name="list" id="vo">
								<tr>
									<td>{$vo.id}</td>
									 <td class="wd">{$vo.name}</td>
									<td class="align-center">
										{$vo.createtime|date='Y-m-d',###}
									</td>
									<td class="align-center">
										{$vo.last_time|date='Y-m-d',###}
									</td>
									 <td class="align-center">{$vo.last_ip}</td>
									<td class="align-center">
									{$vo.gname}
									</td>
									<td class="align-center">
									<if condition="$vo.status eq '0'">正常</if>
									<if condition="$vo.status eq '1'">禁止</if>
									</td>
									<td class="align-center">
										<if condition="$level eq '2'">
										<a class="label label-primary" role="button" data-toggle="modal" href="#edit" data-id="{$vo.id}" data-name="{$vo.name}" data-gid="{$vo.gid}" data-type="admin_edit">修改</i>
										</a>
										<if condition="$vo.gr_status eq '1'">
										<a href="javascript:;" data-id="{$vo.id}" data-type="admin_del">			
										&nbsp;
										<span class="label label-danger" data-status="3" >删除</span>
										</a>
										</if>
										</if>								
									 </td>

								</tr>
								</volist>
							  </tbody>
						  </table>  
							<ul class="pagination">
								{$page}
							 </ul>						  
						</div>
					</div>
				</div><!--/col-->
			
			</div><!--/row-->				
			
		<!-- end: Content -->
		<br><br><br>
		
	</div><!--/container-->
<!--添加新会员-->	
        <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="again" class="modal fade add_right">
		
            <div class="modal-dialog public-top"  id="">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="title">添加管理员</h4>
                    </div>
					<form action="{:U('Admin/addAdmin')}" method="post" class="form-horizontal" id="action">
						<div class="modal-body">
							<label class="">管理员账号:</label>
							<div class="">
								<input type="text" id="adminname" name="adminname" value="" class="form-control placeholder-no-fix" >
							</div></br>
							<label class="">密码:</label>
							<div class="">
								<input type="password" id="password" name="password" class="form-control placeholder-no-fix" placeholder="不填，则默认密码为123456">
							</div></br>

							<label class="">管理组:</label>
							<div class="">
								<select id="gid" name="gid" class="form-control" size="1">
									<option value="">请选择</option>
									<foreach name="set_list" item="vo">
									<option value="{$vo.id}">{$vo.gname}</option>
									</foreach>					
								 </select>							
				            </div></br>
						</div></br>
						<input type="hidden"  name="id" id="id" value="">
						<input type="hidden"  name="type" id="type" value="admin_add">
						<div class="modal-footer">
							<button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
							<button class="btn btn-primary mypost" type="sunmit">确认</button>
						</div>
					</form>	
              </div>
            </div>
        </div>		
</block>
<block name="script">
<script>
$("#add_right").click(function(){
	$(".add_right").attr('id','again');
	$("#title").html('添加管理员');
	$("#adminname").val('');
	$("#password").val('');
	$("#password").attr('placeholder','不填，则默认密码为123456');
	$("#gid").val('');
	$("#id").val('');
	$("#type").val('admin_add');
});


$("[data-type='admin_edit']").click(function(){
	
    var id = $(this).attr('data-id');
	var state = $(this).find('span').attr('data-status');
	
	var type = $(this).attr('data-type');
	var adminname = $(this).attr('data-name');
	var gid = $(this).attr('data-gid');
	
	if (id && type) {
		$(".add_right").attr('id','edit');
		$("#gid").val(gid);
		$("#title").html('修改管理员');
		$("#adminname").val(adminname);
		$("#password").attr('placeholder','不填，则密码不变');
		$("#id").val(id);
		if (id==='1') {
			//alert(id);	
			$("#gid").attr('disabled',"disabled");
		} else {
			$("#gid").removeAttr('disabled');
		}
		$("#type").val('admin_edit');	
		
	}

});

$("[data-type='admin_del']").click(function(){
	
    var id = $(this).attr('data-id');
	var state = $(this).find('span').attr('data-status');
	
	var type = $(this).attr('data-type');
	
	if (id && type) {
		if(confirm("确定要删除吗？")){	
			$.ajax({
				url:"{:U('Admin/addAdmin')}",
				data:{id:id,state:state,type:type},
				type:'post',
				dataType:'json',
				success:function (e) {			
				//alert(e.info);
					if (e.info==1) {
						alert('删除成功');
						location.reload();
					} else if(e.info==4){
						alert('删除失败');
					} 
				
				}
			});	
		}
	}  

});
</script>
</block>	









